import Vue from 'vue'
import VueRouter from 'vue-router'

// 全局注册 两个组件： router-view / router-link
Vue.use(VueRouter)

// 路由表
const routes = [
  {
    path: '/login',
    component: () => import('@/views/login/index.vue')
  },
  {
    path: '/', // #/
    component: () => import('@/views/layout/index.vue'),
    children: [
      {
        path: '', // 默认子路由
        component: () => import('@/views/home/index.vue')
      }, {
        path: '/qa', // #/qa
        component: () => import('@/views/qa/index.vue')
      }, {
        path: '/video',
        component: () => import('@/views/video/index.vue')
      }, {
        path: '/my',
        component: () => import('@/views/my/index.vue')
      }
    ]
  },
  {
    path: '/search',
    component: () => import('@/views/search/index.vue')
  },
  {
    name: 'art',
    path: '/article/:aid',
    component: () => import('@/views/article/index.vue'),
    props: true // 开启路由传参：路由为 组件 的 props 传参
  },
  {
    path: '/profile',
    component: () => import('@/views/profile/index.vue')
  }
]

// 路由管理器
const router = new VueRouter({
  routes
})

// 导出路由管理器
export default router
